<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>png++: require_color_space.hpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">png++
   &#160;<span id="projectnumber">0.2.1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">require_color_space.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="require__color__space_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2007,2008   Alex Shulgin</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * This file is part of png++ the C++ wrapper for libpng.  PNG++ is free</span>
<a name="l00005"></a>00005 <span class="comment"> * software; the exact copying conditions are as follows:</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00008"></a>00008 <span class="comment"> * modification, are permitted provided that the following conditions are met:</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * 1. Redistributions of source code must retain the above copyright notice,</span>
<a name="l00011"></a>00011 <span class="comment"> * this list of conditions and the following disclaimer.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
<a name="l00014"></a>00014 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span>
<a name="l00015"></a>00015 <span class="comment"> * documentation and/or other materials provided with the distribution.</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> * 3. The name of the author may not be used to endorse or promote products</span>
<a name="l00018"></a>00018 <span class="comment"> * derived from this software without specific prior written permission.</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS&#39;&#39; AND ANY EXPRESS OR</span>
<a name="l00021"></a>00021 <span class="comment"> * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</span>
<a name="l00022"></a>00022 <span class="comment"> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN</span>
<a name="l00023"></a>00023 <span class="comment"> * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
<a name="l00024"></a>00024 <span class="comment"> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED</span>
<a name="l00025"></a>00025 <span class="comment"> * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR</span>
<a name="l00026"></a>00026 <span class="comment"> * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF</span>
<a name="l00027"></a>00027 <span class="comment"> * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00028"></a>00028 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00029"></a>00029 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00030"></a>00030 <span class="comment"> */</span>
<a name="l00031"></a>00031 <span class="preprocessor">#ifndef PNGPP_REQUIRE_COLOR_SPACE_HPP_INCLUDED</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#define PNGPP_REQUIRE_COLOR_SPACE_HPP_INCLUDED</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="error_8hpp.html">error.hpp</a>&quot;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="rgb__pixel_8hpp.html">rgb_pixel.hpp</a>&quot;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &quot;<a class="code" href="rgba__pixel_8hpp.html">rgba_pixel.hpp</a>&quot;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &quot;<a class="code" href="gray__pixel_8hpp.html">gray_pixel.hpp</a>&quot;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &quot;<a class="code" href="ga__pixel_8hpp.html">ga_pixel.hpp</a>&quot;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &quot;<a class="code" href="index__pixel_8hpp.html">index_pixel.hpp</a>&quot;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &quot;<a class="code" href="io__base_8hpp.html">io_base.hpp</a>&quot;</span>
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="keyword">namespace </span>png
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044 
<a name="l00045"></a>00045     <span class="keyword">namespace </span>detail
<a name="l00046"></a>00046     {
<a name="l00047"></a>00047 
<a name="l00048"></a>00048         <span class="keyword">template</span>&lt; <span class="keyword">typename</span> pixel &gt;
<a name="l00049"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html">00049</a>         <span class="keyword">struct </span><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html">wrong_color_space</a>
<a name="l00050"></a>00050         {
<a name="l00051"></a>00051             <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">char</span> <span class="keyword">const</span>* <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">error_msg</a>();
<a name="l00052"></a>00052         };
<a name="l00053"></a>00053 
<a name="l00054"></a>00054         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00055"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a0ad4320001926e0ee08c6e11bb7bc7d1">00055</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; rgb_pixel &gt;::error_msg</a>()
<a name="l00056"></a>00056         {
<a name="l00057"></a>00057             <span class="keywordflow">return</span> <span class="stringliteral">&quot;8-bit RGB color space required&quot;</span>;
<a name="l00058"></a>00058         }
<a name="l00059"></a>00059 
<a name="l00060"></a>00060         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00061"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#aec057ff96ab74d70c54b872444ddc6bb">00061</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; rgb_pixel_16 &gt;::error_msg</a>()
<a name="l00062"></a>00062         {
<a name="l00063"></a>00063             <span class="keywordflow">return</span> <span class="stringliteral">&quot;16-bit RGB color space required&quot;</span>;
<a name="l00064"></a>00064         }
<a name="l00065"></a>00065 
<a name="l00066"></a>00066         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00067"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a55da06a06c6273156830478b5c216f24">00067</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; rgba_pixel &gt;::error_msg</a>()
<a name="l00068"></a>00068         {
<a name="l00069"></a>00069             <span class="keywordflow">return</span> <span class="stringliteral">&quot;8-bit RGBA color space required&quot;</span>;
<a name="l00070"></a>00070         }
<a name="l00071"></a>00071 
<a name="l00072"></a>00072         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00073"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a28766517b1a8dc6c17458c13a3955f1c">00073</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; rgba_pixel_16 &gt;::error_msg</a>()
<a name="l00074"></a>00074         {
<a name="l00075"></a>00075             <span class="keywordflow">return</span> <span class="stringliteral">&quot;16-bit RGBA color space required&quot;</span>;
<a name="l00076"></a>00076         }
<a name="l00077"></a>00077 
<a name="l00078"></a>00078         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00079"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a59a4f04b58ac3ad836d86166f46444f8">00079</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; gray_pixel &gt;::error_msg</a>()
<a name="l00080"></a>00080         {
<a name="l00081"></a>00081             <span class="keywordflow">return</span> <span class="stringliteral">&quot;8-bit Grayscale color space required&quot;</span>;
<a name="l00082"></a>00082         }
<a name="l00083"></a>00083 
<a name="l00084"></a>00084         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00085"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#ad1c7b97bde0bd5bb895f2c722fe2aec8">00085</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; gray_pixel_1 &gt;::error_msg</a>()
<a name="l00086"></a>00086         {
<a name="l00087"></a>00087             <span class="keywordflow">return</span> <span class="stringliteral">&quot;1-bit Grayscale color space required&quot;</span>;
<a name="l00088"></a>00088         }
<a name="l00089"></a>00089 
<a name="l00090"></a>00090         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00091"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#ac22147f0b574ea511fd7920f53f2f2eb">00091</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; gray_pixel_2 &gt;::error_msg</a>()
<a name="l00092"></a>00092         {
<a name="l00093"></a>00093             <span class="keywordflow">return</span> <span class="stringliteral">&quot;2-bit Grayscale color space required&quot;</span>;
<a name="l00094"></a>00094         }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00097"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#aea2f989d9f12be65ca66e9e9da4dadd3">00097</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; gray_pixel_4 &gt;::error_msg</a>()
<a name="l00098"></a>00098         {
<a name="l00099"></a>00099             <span class="keywordflow">return</span> <span class="stringliteral">&quot;4-bit Grayscale color space required&quot;</span>;
<a name="l00100"></a>00100         }
<a name="l00101"></a>00101 
<a name="l00102"></a>00102         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00103"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a2238db64d7231f5d3fef3769f0468f2b">00103</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; gray_pixel_16 &gt;::error_msg</a>()
<a name="l00104"></a>00104         {
<a name="l00105"></a>00105             <span class="keywordflow">return</span> <span class="stringliteral">&quot;16-bit Grayscale color space required&quot;</span>;
<a name="l00106"></a>00106         }
<a name="l00107"></a>00107 
<a name="l00108"></a>00108         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00109"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#adbf0ab3d92e4bbc0d1854e9c70d3187a">00109</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; ga_pixel &gt;::error_msg</a>()
<a name="l00110"></a>00110         {
<a name="l00111"></a>00111             <span class="keywordflow">return</span> <span class="stringliteral">&quot;8-bit Gray+Alpha color space required&quot;</span>;
<a name="l00112"></a>00112         }
<a name="l00113"></a>00113 
<a name="l00114"></a>00114         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00115"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a7fa91909644b8047c674591d3c83df8d">00115</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; ga_pixel_16 &gt;::error_msg</a>()
<a name="l00116"></a>00116         {
<a name="l00117"></a>00117             <span class="keywordflow">return</span> <span class="stringliteral">&quot;16-bit Gray+Alpha color space required&quot;</span>;
<a name="l00118"></a>00118         }
<a name="l00119"></a>00119 
<a name="l00120"></a>00120         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00121"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#adf1b5b62959c672f2401ff3250cef13c">00121</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; index_pixel &gt;::error_msg</a>()
<a name="l00122"></a>00122         {
<a name="l00123"></a>00123             <span class="keywordflow">return</span> <span class="stringliteral">&quot;8-bit Colormap color space required&quot;</span>;
<a name="l00124"></a>00124         }
<a name="l00125"></a>00125 
<a name="l00126"></a>00126         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00127"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#adbddb391292383e55fdf9abb61eb2492">00127</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; index_pixel_1 &gt;::error_msg</a>()
<a name="l00128"></a>00128         {
<a name="l00129"></a>00129             <span class="keywordflow">return</span> <span class="stringliteral">&quot;1-bit Colormap color space required&quot;</span>;
<a name="l00130"></a>00130         }
<a name="l00131"></a>00131 
<a name="l00132"></a>00132         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00133"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a0d9072c556613f78296564b395ed907e">00133</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; index_pixel_2 &gt;::error_msg</a>()
<a name="l00134"></a>00134         {
<a name="l00135"></a>00135             <span class="keywordflow">return</span> <span class="stringliteral">&quot;2-bit Colormap color space required&quot;</span>;
<a name="l00136"></a>00136         }
<a name="l00137"></a>00137 
<a name="l00138"></a>00138         <span class="keyword">template</span>&lt;&gt; <span class="keyword">inline</span> <span class="keywordtype">char</span> <span class="keyword">const</span>*
<a name="l00139"></a><a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a1348c776fd8f3f78101c72f21f9df52e">00139</a>         <a class="code" href="structpng_1_1detail_1_1wrong__color__space.html#a396ea47c6dd562c8603e22d365ab2068">wrong_color_space&lt; index_pixel_4 &gt;::error_msg</a>()
<a name="l00140"></a>00140         {
<a name="l00141"></a>00141             <span class="keywordflow">return</span> <span class="stringliteral">&quot;4-bit Colormap color space required&quot;</span>;
<a name="l00142"></a>00142         }
<a name="l00143"></a>00143 
<a name="l00144"></a>00144     } <span class="comment">// namespace detail</span>
<a name="l00145"></a>00145 
<a name="l00154"></a>00154     <span class="keyword">template</span>&lt; <span class="keyword">typename</span> pixel &gt;
<a name="l00155"></a><a class="code" href="structpng_1_1require__color__space.html">00155</a>     <span class="keyword">struct </span><a class="code" href="structpng_1_1require__color__space.html" title="IO transformation class template. Enforces image color space.">require_color_space</a>
<a name="l00156"></a>00156     {
<a name="l00157"></a><a class="code" href="structpng_1_1require__color__space.html#a95fc4a1f8f4cd72c19e0123030970d04">00157</a>         <span class="keyword">typedef</span> pixel_traits&lt; pixel &gt; <a class="code" href="structpng_1_1require__color__space.html#a95fc4a1f8f4cd72c19e0123030970d04">traits</a>;
<a name="l00158"></a>00158 
<a name="l00159"></a><a class="code" href="structpng_1_1require__color__space.html#a7d6f4b921d201c3e4e1f80d137a4b33e">00159</a>         <span class="keywordtype">void</span> <a class="code" href="structpng_1_1require__color__space.html#a7d6f4b921d201c3e4e1f80d137a4b33e">operator()</a>(<a class="code" href="classpng_1_1io__base.html" title="Base class for PNG reader/writer classes.">io_base</a>&amp; io)<span class="keyword"> const</span>
<a name="l00160"></a>00160 <span class="keyword">        </span>{
<a name="l00161"></a>00161             <span class="keywordflow">if</span> (io.<a class="code" href="classpng_1_1io__base.html#ab8070ca679dfb49c226978297e7b4c08">get_color_type</a>() != traits::get_color_type()
<a name="l00162"></a>00162                 || io.<a class="code" href="classpng_1_1io__base.html#a391152531f1825e81460b9847a3a8000">get_bit_depth</a>() != traits::get_bit_depth())
<a name="l00163"></a>00163             {
<a name="l00164"></a>00164                 <span class="keywordflow">throw</span> <a class="code" href="classpng_1_1error.html" title="Exception class to represent runtime errors related to png++ operation.">error</a>(<a class="code" href="structpng_1_1detail_1_1wrong__color__space.html">detail::wrong_color_space&lt; pixel &gt;::error_msg</a>());
<a name="l00165"></a>00165             }
<a name="l00166"></a>00166         }
<a name="l00167"></a>00167     };
<a name="l00168"></a>00168 
<a name="l00169"></a>00169 } <span class="comment">// namespace png</span>
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 <span class="preprocessor">#endif // PNGPP_REQUIRE_COLOR_SPACE_HPP_INCLUDED</span>
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Fri Jan 25 2013 14:10:10 for png++ by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
